home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctjjl86.arc
/
ANIMATE.ARC
/
XORBENCH.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-04-16
|
6KB
|
196 lines
; *** Listing 2 ***
;
;This program benchmarks exclusive-OR drivers.
;Link the XOR form_driver module to this program.
;
stack segment para stack 'STACK'
db 512 dup(0)
stack ends
;
one segment para public 'CODE'
assume cs:one,ds:one,es:nothing
extrn form_driver:near
;
iteration_count dw 0
;
;Lists describing image, location, and motion of 8 objects.
;
form_address dw f0, f1, f2, f3, f3, f2, f1, f0 ;pointers to form
; byte strings for
; each object
highest_object_pointer equ (($-form_address)-2) ;the index for the
; last object in
; these lists
;in scan lines (0 - 198):
row dw 100,100,100,100,100,100,100,100
;in bytes (0 - 79):
column dw 32, 32, 32, 32, 32, 32, 32, 32
;in scan lines (0 - 198):
row_increment dw -2, 2, 0, -2, 0, 0, -2, 2
;in bytes (0 - 79):
column_increment dw 1, 1, 0, -1, 1, -1, 0, -1
;byte number on line (0-79):
left_margin dw 0, 0, 0, 0, 0, 0, 0, 0
;byte number on line (0-79):
right_margin dw 76, 74, 72, 70, 70, 72, 74, 76
;line number (0 - 198):
top_margin dw 0, 0, 0, 0, 0, 0, 0, 0
;line number (0 - 198):
bottom_margin dw 194,184,174,164,164,174,184,194
;
;Form byte structures, as follows:
; byte 1: # of scan lines in forms.
; byte 2: # of bytes per scan line of form.
; byte 3: first byte of image, followed by rest of bytes
; forming image, with bytes for top scan line,
; left to right, first, second scan line next,
; and so on.
;
f0 db 6,4
db 0f0h,00fh,0f0h,00fh
db 0f0h,03fh,0fch,00fh
db 0ffh,0ffh,0ffh,0ffh
db 0f0h,0ffh,0ffh,00fh
db 0f0h,03fh,0fch,00fh
db 0f0h,00fh,0f0h,00fh
f1 db 16,6
db 4 dup(6 dup(055h))
db 4 dup(6 dup(0ffh))
db 4 dup(6 dup(0aah))
db 4 dup(6 dup(055h))
f2 db 26,8
db 26 dup(0ffh,0aah,0aah,055h,055h,0aah,0aah,0ffh)
f3 db 36,10
db 9 dup(10 dup(0ffh))
db 3 dup(0ffh,0ffh,6 dup(0aah),0ffh,0ffh)
db 3 dup(0ffh,0ffh,0aah,4 dup(055h),0aah,0ffh,0ffh)
db 6 dup(0ffh,0ffh,0aah,055h,000h,000h,055h,0aah,0ffh,0ffh)
db 3 dup(0ffh,0ffh,0aah,4 dup(055h),0aah,0ffh,0ffh)
db 3 dup(0ffh,0ffh,6 dup(0aah),0ffh,0ffh)
db 9 dup(10 dup(0ffh))
;
start proc far
push ds ;set up for return to DOS
sub ax,ax ; through the instruction at DS:0 set
push ax ; up by DOS when it loads this program
cld ;drivers count up
push cs
pop ds ;DS and CS are to be the same
mov ax,0b800h ;ES is to point to Color Graphics
mov es,ax ; Adapter's memory buffer
mov ax,0004h ;set 320x200 color mode
int 10h ;
;
;Start by drawing all the images at their starting locations
;
mov si,highest_object_pointer ;start at last object
next_initial_draw:
push si ;save the object index
mov bx,[si+row] ;get the line at which to put
; this object
mov cx,[si+column] ;get the column for this object
mov si,[si+form_address] ;get the address of the
; object's image
call form_driver ;put image to screen memory
pop si ;restore the object index
sub si,2 ;point to next object to draw
jns next_initial_draw ;if not done draw next object
;
;Set number of times to move objects
;
mov [iteration_count],700 ;number of times to repeat
; move loop
;
;For each iteration, move each object in turn by erasing it,
; moving it one increment, and drawing it at the new position.
;
next_iteration:
mov si,highest_object_pointer ;start at last object
;
;Move each object in turn.
;
move_next_object:
;
;Erase the object at its present position.
;
push si ;exclusive-ORing an existing
mov bx,[si+row] ; image with itself
mov cx,[si+column] ; effectively erases it
mov si,[si+form_address] ;
call form_driver ;
pop si ;
;
;Advance the object's row and column and adjust increments
; so the object remains within its boundaries.
;
;If adding the row increment to the row would place it outside
; its margins...
;
mov ax,[si+row] ;test the new line position
add ax,[si+row_increment] ; to see if it goes outside
cmp ax,[si+top_margin] ; its limit
jb negate_row_increment ;if outside negate increment
cmp ax,[si+bottom_margin] ; so that it will move towards
jbe test_column_increment ; its other limit
;
;...then make the row increment negative if positive and
; positive if negative.
;
negate_row_increment:
neg [si+row_increment] ;make it move in other direction
;
;If adding the column increment to the column would place it
; outside its margins...
;
test_column_increment:
mov ax,[si+column] ;if the column for the object
add ax,[si+column_increment] ;would go outside its left or
cmp ax,[si+left_margin] ; right limits, then negate
jb negate_column_increment ; its increment so that it
cmp ax,[si+right_margin] ; will move in the opposite
jbe add_increments ; direction
;
;...then make the column increment negative if positive and
; positive if negative.
;
negate_column_increment:
neg [si+column_increment] ;set to move in opposite
; direction
;
;Add the increments to the row and column to arrive at the
; object's next position.
;
add_increments:
mov ax,[si+row_increment] ;calculate the next line
add [si+row],ax ; position and store it
mov ax,[si+column_increment] ;calculate the next column
add [si+column],ax ; position and store it
;
;Draw the object at the new location.
;
push si ;save this object index
mov bx,[si+row] ;find line and column no. at
mov cx,[si+column] ; which to place the object
mov si,[si+form_address] ;find addr. of object's form
call form_driver ;put object's image into screen
pop si ;restore the object index
;
sub si,2 ;point to next object to move
jns move_next_object ; if not done jmp to move it
;
dec [iteration_count] ;count down number of times to
jnz next_iteration ; move all the objects
;
;Reset the mode to 80x25 color text mode.
;
mov ax,0003h ;before returning to DOS, set
int 10h ; screen to 80x25 text mode
;
;Return to DOS.
;
ret ;return though instruction at
; start of PSP set up by DOS
start endp
one ends
end start